<?php
/**
 * This file defines the exception class {@see \BF\MissingExtensionException}.
 *
 * @author     Kado <ulfikado@gmail.com>
 * @category   Beluga PHP5.3+ Framework
 * @package    BF\Core
 * @since      2015-01-17 14:29
 * @subpackage Exceptions
 * @version    0.1
 */

namespace BF
{

   /**
    * This exception should be trown, if a required PHP extension is not loaded.
    *
    * The class extends from {@see \BF\Exception}
    *
    * @since  v0.1
    */
   class MissingExtensionException extends \BF\Exception
   {

      # <editor-fold defaultstate="collapsed" desc=" - - -   P R I V A T E   F I E L D S   - - - - - - - - - - - - - - - - - - - - - -">

      /**
       * The name of the missed PHP extension.
       *
       * @var string
       */
      private $extensionName;

      # </editor-fold>

      # <editor-fold defaultstate="collapsed" desc=" - - >   P U B L I C   C O N S T R U C T O R   - - - - - - - - - - - - - - - - - -">

      /**
       * Inits a new instance.
       *
       * @param string     $extensionName  The name of the missing extension
       * @param string     $message        The error message (default=null)
       * @param mixed      $code           The error code (default=\E_USER_ERROR)
       * @param \Exception $previous       A optional previous exception
       */
      public function __construct(
         $extensionName, $message = null, $code = E_USER_ERROR, \Exception $previous = null )
      {
         parent::__construct(
            \sprintf( 'PHP extension "%s" is not loaded with current PHP config.', $extensionName )
               . self::appendMessage( $message ),
            $code,
            $previous
         );
         $this->extensionName = $extensionName;
      }

      # </editor-fold>

      # <editor-fold defaultstate="collapsed" desc=" * *   G E T T E R S   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *">

      /**
       * Returns the name of the missed extension.
       *
       * @return string
       */
      final public function getExtensionName()
      {
         return $this->extensionName;
      }

      # </editor-fold>

   }

}

